package cn.tedu;

import java.sql.*;

public class demo03 {
    public static void main (String[] args) throws SQLException {
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/empdb?characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false",
        "root","root");

        Statement s = conn.createStatement();

        //s.executeUpdate("insert into emp(name) values('Tom')");
        //s.executeUpdate("update emp set name='Jerry' where name = 'Tom'");
        //s.executeUpdate("delete from emp where name = 'Jerry'");
        ResultSet rs = s.executeQuery("select name,sal,job from emp");
        //遍历返回数据,rs.next()
        while(rs.next()){
            String name = rs.getString("name");
            double sal = rs.getDouble("sal");
            String job = rs.getString("job");
            System.out.println(name+":"+sal+":"+job);
        }
        conn.close();
    }
}
